package com.zmyuan.demo.netty.combine.codec;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.Delimiters;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * Created by zdb on 2017/2/18.
 */
public class CombineEncoder extends MessageToByteEncoder<String> {

    protected void encode(ChannelHandlerContext ctx, String msg, ByteBuf out) throws Exception {
        out.writeBytes(msg.getBytes("UTF-8"));
        out.writeBytes(Delimiters.lineDelimiter()[0]);
    }
}
